import Vue from "vue";
import VueI18n from "vue-i18n";

import ElementLocale from "element-ui/lib/locale";
import enLocale from "element-ui/lib/locale/lang/en";
import zhLocale from "element-ui/lib/locale/lang/zh-CN";

import langZh from "./zh/zh.json";
import langEN from "./en/en.json";

Vue.use(VueI18n);

const i18n = new VueI18n({
  locale: window.localStorage.getItem("lang") || "zh",
  messages: {
    zh: { ...langZh, ...zhLocale },
    en: { ...langEN, ...enLocale }
  },
  silentTranslationWarn: true // 去除国际化警告
});
ElementLocale.i18n((key, value) => i18n.t(key, value));

export default i18n;
